package edu.etu.sob.service;

import java.util.HashMap;

import com.hp.hpl.jena.ontology.OntModel;

public class OntologyProvider {
	
	private static OntologyProvider instance = null;
	private HashMap<String, OntModel> ontologies = new HashMap<String, OntModel>();
	
	private OntologyProvider() {
		
	}
	
	public static OntologyProvider getInstance() {
		if (instance == null)
			instance = new OntologyProvider();
		return instance;
	}
	
	public void cacheModel(final OntModel model) {
		ontologies.put(model.getNsPrefixURI(null), model);
	}
	
	public OntModel getModel(String url) {
		return isModelAvailable(url) ? ontologies.get(url) : null;
	}
	
	public boolean isModelAvailable(String url) {
		return ontologies.containsKey(url);
	}
	
}
